<?php

namespace App\Console\Commands;

use App\Models\Appoint;
use Illuminate\Console\Command;

class hospitalAppointDone extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:hospital-appoint-done';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $day = date('Y-m-d');
        $appoint = Appoint::query()
            ->whereIn('status',[1,5])
            ->where('appoint_date','<',$day)
            ->get();
        foreach($appoint as $k=>$v){
            $v->status = 4;
            $v->save();
        }
        return 0;
    }
}
